package com.itheima.controller;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.itheim.client.vo.CategoryVo;
import com.itheima.common.R;
import com.itheima.service.CCategoryService;
import lombok.extern.log4j.Log4j2;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * @Author longbosheng
 * @Date 2022/6/19 19:02
 * @PackageName:com.itheima.controller
 * @ClassName: CategoryController
 * @Description: TODO
 * @Version 1.0
 */
@Log4j2
@RestController
@RequestMapping("/category")
public class CategoryController {
    @Resource
    private CCategoryService ccategoryService;
    /**
     * 分类列表
     * @return
     */
    @GetMapping("/list")
    public R categoryList(){
        LambdaQueryWrapper<CategoryVo> wrapper = new LambdaQueryWrapper<>();
        wrapper.orderByDesc(CategoryVo::getSort);
        List<CategoryVo> list = ccategoryService.list(wrapper);
        System.out.println(list);
        return R.success(list);
    }
}
